package com.ruoyi.web.controller.construcitoncost;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.ProApplicationPayment;
import com.ruoyi.domain.SiteFeeSchedule;
import com.ruoyi.service.ISiteFeeScheduleService;
import com.ruoyi.system.domain.ProCreateBuilding;
import com.ruoyi.system.service.IProCreateBuildingService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
/**
 * 财务的工地安全质量费用Controller
 *
 * @author ruoyi
 * @date 2020-06-18
 */
@Controller
@RequestMapping("/ruoyi/constructionCost")
public class ConstructionCostController extends BaseController
{
    private String prefix = "ruoyi/constructionCost";

    @Autowired
    private ISiteFeeScheduleService siteFeeScheduleService;
    @Autowired
    private IProCreateBuildingService proCreateBuildingService;

    @RequiresPermissions("ruoyi:constructionCost:view")
    @GetMapping()
    public String constructionCost()
    {
        return prefix + "/constructionCost";
    }

    /**
     * 查询项目列表
     */
    @RequiresPermissions("ruoyi:constructionCost:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProCreateBuilding proCreateBuilding)
    {
        startPage();
        List<ProCreateBuilding> list = proCreateBuildingService.selectProCreateBuildingList(proCreateBuilding);
        return getDataTable(list);
    }

    //根据项目id查询工地安全质量费用列表
    @RequiresPermissions("ruoyi:constructionCost:list")
    @PostMapping("/sId")
    @ResponseBody
    public TableDataInfo sId(String sId){
        startPage();//分页
        List<SiteFeeSchedule> list =siteFeeScheduleService.selectBid(sId);
        return getDataTable(list);// 返回前台
    }

    /**
     * 导出付款申请单合同费用
     */
    @Log(title = "工地安全质量费用数据", businessType = BusinessType.EXPORT)
    @RequiresPermissions("ruoyi:constructionCost:exports")
    @PostMapping("/exports")
    @ResponseBody
    public AjaxResult exports(SiteFeeSchedule siteFeeSchedule)
    {
        List<SiteFeeSchedule> list = siteFeeScheduleService.selectUserexport(siteFeeSchedule);
        ExcelUtil<SiteFeeSchedule> util = new ExcelUtil<SiteFeeSchedule>(SiteFeeSchedule.class);
        return util.exportExcel(list, "工地安全质量费用数据");
    }

}
